/*
 * @Author: szx
 * @Date: 2021-11-23 16:59:19
 * @LastEditTime: 2021-11-23 17:06:13
 * @Description:
 * @FilePath: \leetcode\400-499\413\413.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var numberOfArithmeticSlices = function (nums) {
    let dp = nums[0] - nums[1];
    let res = 0;
    let tmp = 0;
    for (let i = 2; i < nums.length; i++) {
        if (nums[i - 1] - nums[i] == dp) {
            tmp++;
        } else {
            dp = nums[i - 1] - nums[i];
            tmp = 0;
        }
        res += tmp;
    }
    return res;
};
